<%@ page language="java" pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<HTML>
<HEAD>
  <meta http-equiv="Content-Language" content="zh-cn">
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link href="${pageContext.request.contextPath}/css/Style1.css" rel="stylesheet"
        type="text/css"/>
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css"
        type="text/css"/>
  <script src="${pageContext.request.contextPath}/js/jquery-2.1.4.min.js"
          type="text/javascript"></script>
  <script src="${pageContext.request.contextPath}/js/bootstrap-3.1.1.min.js"
          type="text/javascript"></script>
</HEAD>
<body>
<br>
<form id="Form1" name="Form1" action="${pageContext.request.contextPath}/user/list.jsp"
      method="post">
  <table cellSpacing="1" cellPadding="0" width="100%" align="center" bgColor="#f5fafe" border="0">
    <TBODY>
    <tr>
      <td class="ta_01" align="center" bgColor="#afd1f3">
        <strong>商品列表</strong>
      </TD>
    </tr>
    <tr>
      <td class="ta_01" align="right">
        <button type="button" id="add" name="add" value="添加" class="button_add"
                onclick="addProduct()">
          &#28155;&#21152;
        </button>

      </td>
    </tr>
    <tr>
      <td class="ta_01" align="center" bgColor="#f5fafe">
        <table cellspacing="0" cellpadding="1" rules="all"
               bordercolor="gray" border="1" id="DataGrid1"
               style="BORDER-RIGHT: gray 1px solid; BORDER-TOP: gray 1px solid; BORDER-LEFT: gray 1px solid; WIDTH: 100%; WORD-BREAK: break-all; BORDER-BOTTOM: gray 1px solid; BORDER-COLLAPSE: collapse; BACKGROUND-COLOR: #f5fafe; WORD-WRAP: break-word">
          <tr style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; HEIGHT: 25px; BACKGROUND-COLOR: #afd1f3">

            <td align="center" width="18%">
              序号
            </td>
            <td align="center" width="17%">
              商品图片
            </td>
            <td align="center" width="17%">
              商品名称
            </td>
            <td align="center" width="17%">
              商品价格
            </td>
            <td align="center" width="17%">
              是否热门
            </td>
            <td width="7%" align="center">
              编辑
            </td>
            <td width="7%" align="center">
              删除
            </td>
          </tr>
          <c:forEach items="${page.list}" var="p" varStatus="vs">
            <tr onmouseover="this.style.backgroundColor = 'white'"
                onmouseout="this.style.backgroundColor = '#F5FAFE';">
              <td style="CURSOR: hand; HEIGHT: 22px" align="center"
                  width="18%">
                  ${p.pid}
              </td>
              <td style="CURSOR: hand; HEIGHT: 22px" align="center"
                  width="17%">
                <img width="40" height="45"
                     src="/${p.image}">
              </td>
              <td style="CURSOR: hand; HEIGHT: 22px" align="center"
                  width="17%">
                  ${p.name}
              </td>
              <td style="CURSOR: hand; HEIGHT: 22px" align="center"
                  width="17%">
                  ${p.shopPrice}
              </td>
              <td style="CURSOR: hand; HEIGHT: 22px" align="center"
                  width="17%">
                <c:if test="${p.isHot==1 }">是</c:if>
                <c:if test="${p.isHot!=1 }">否</c:if>
              </td>
              <td align="center" style="HEIGHT: 22px">
                <a href="${pageContext.request.contextPath}/admin/productGoEdit.do?pid=${p.pid}&pageid=${page.page}">
                  <img src="${pageContext.request.contextPath}/images/i_edit.gif"
                       border="0" style="CURSOR: hand">
                </a>
              </td>

              <td align="center" style="HEIGHT: 22px">
                <button type="button" class="btn btn-sm"
                        data-toggle="modal" data-target="#myModal${vs.count}">
                  <img src="${pageContext.request.contextPath}/images/i_del.gif"
                       width="16" height="16" border="0" style="CURSOR: hand">
                </button>
                <div class="modal fade bs-example-modal-sm" id="myModal${vs.count}"
                     tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                  <div class="modal-dialog" role="document">
                    <div class="modal-content">
                      <div class="modal-header">
                        <button type="button" class="close"
                                data-dismiss="modal" aria-label="Close">
                          <span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">确定删除吗</h4>
                      </div>
                        ${p.pid}
                      <div class="modal-footer">
                        <button type="button" class="btn"
                                data-dismiss="modal">取消
                        </button>
                        <button type="button" class="btn"
                                onclick="elete('${p.pid}')">确认
                        </button>
                      </div>
                    </div>
                  </div>
                </div>
              </td>
            </tr>
          </c:forEach>
        </table>
      </td>
    </tr>

    <tr>
      <td>
        <div style="width:380px;margin:0 auto;margin-top:50px;">
          <ul class="pagination" style="text-align:center; margin-top:10px;">
            <li>
              <a href="${pageContext.request.contextPath}/admin/adminFindAllProduct.do?page=${page.prePage}"
                 aria-label="Previous"><span aria-hidden="true">&laquo;</span></a>
            </li>

            <c:forEach begin="${page.navigateFirstPage}"
                       end="${page.navigateLastPage}" var="i">
              <c:if test="${page.page != i}">
                <li>
                  <a href="${pageContext.request.contextPath}/admin/adminFindAllProduct.do?page=${i}">${i}</a>
                </li>
              </c:if>
              <c:if test="${page.page == i}">
                <li class="active">
                  <a href="${pageContext.request.contextPath}/admin/adminFindAllProduct.do?page=${i}">${i}</a>
                </li>
              </c:if>
            </c:forEach>

            <li>
              <a href="${pageContext.request.contextPath}/admin/adminFindAllProduct.do?page=${page.nextPage}"
                 aria-label="Next">
                <span aria-hidden="true">&raquo;</span>
              </a>
            </li>

          </ul>
        </div>
      </td>
    </tr>


    </TBODY>
  </table>
</form>
</body>
<script type="text/javascript">
  function addProduct() {
    location.href = "/admin/productGoAdd.do";
  }

  function elete(e) {
    location.href = "${pageContext.request.contextPath}/admin/adminDeleteProduct.do?pid=" + e;
  }
</script>
</HTML>

